package 集合泛型;

import java.util.ArrayList;
import java.util.List;

public class 泛型的使用 {
    public static void main(String[] args) {
        List<String> list=new ArrayList<>();
        list.add("haha");
        list.addAll(1,List.of("php","python","java","python","ruby","python"));
        System.out.println(list.contains("java"));//判断元素中是否含有Java，有返回true

        System.out.println(list);
        System.out.println(list.get(1));
       // list.remove("python");只能删除从左到右第一个python
        //list.remove(3)//删除指定位置的python
        list.removeAll(List.of("python"));//删除所有的python
        System.out.println(list);
        System.out.println(list.get(1));
        //删除所有的元素，清空集合
        list.clear();
        //返回list元素个数
        System.out.println(list.size());
    }

    public static void main1(String[] args) {
        var list=new ArrayList<String>();
        list.add("哈哈");
        list.add(0,"java");
        //String可以只写一个，不写为object
        List<String> list1=new ArrayList<>();
        System.out.println(list);//输出[java 哈哈]
        System.out.println(list.get(0));//java

    }
}
